package producer;


import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper;

import model.Student;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import picture.BaseService_Picture;
import picture.BaseServiceofPicture;

public class Test_Producer {
	
	public static JSONObject BuildJson(Student s)
	{
		JSONObject jObject = new JSONObject();
		jObject.put("student", s);
		System.out.println(jObject);		
		jObject.put("picture", BaseService_Picture.pic2string(s.getPicPath()));
		return jObject;
	}
	
	public static void ParseJson(JSONObject jObject,String path)
	{
		
		JSONObject student = (JSONObject)jObject.get("student");
		System.out.println(student.getInt("id")+student.getString("name")+student.getInt("age"));
		String xxx = jObject.get("picture").toString();
			
		BaseService_Picture.string2pic(xxx, path);
	}
}
